<template>
	<div>孙子组件</div>
	<div>通过provide/inject传递：{{ value1 }}{{ value2 }}</div>

	<button @click="sentEmit">发布全局事件总线事件</button>

	<Slots>
		<template v-slot:default><h2>我是默认插槽</h2></template>

		<template #header><h2>我是具名插槽</h2></template>

		<template #footer="xxx"
			><h2>我是...{{ xxx.msg }}...插槽</h2></template
		>
	</Slots>
</template>

<script>
import { defineComponent } from "vue";
export default defineComponent({
	name: "Three",
});
</script>

<script setup>
import Slots from "./Slots.vue";
import { inject } from "vue";
// 子组件通过inject函数可以声明需要接收的数据
// inject可以传入数组或者字符串,但是一次只能接收一个provide暴露的数据
const value2 = inject("value2");
const value1 = inject(["value1"]);
// const value = inject(["value1", "value2"]);错误示范

//
import myBus from "../../myBus";
const sentEmit = () => {
	myBus.emit("ddd", "haha,收到请回复");
};
</script>
